package net.lainiao.morethread.Chapter2.demo5;

/**
 * Created by Administrator on 2017/2/28.
 */
public class Writer implements Runnable {
    private PriceInfo priceInfo;

    public Writer(PriceInfo priceInfo) {
        this.priceInfo = priceInfo;
    }

    @Override
    public void run() {
        for (int i = 0; i <3 ; i++) {
            System.out.println("Writer :Attempt to modify the prices");
            priceInfo.setPrices(Math.random()*10,Math.random()*8);
            System.out.println("Writer: Pirces have been modified.");
            try {
                Thread.sleep(2);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
